package com.lexed.carmanager.controllor;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lexed.carmanager.database.pojo.Driver;
import com.lexed.carmanager.service.DriverService;

/**
 * Servlet implementation class AddUserServlet
 */
public class AddUserServlet extends HttpServlet {
	
	private DriverService driverService = new DriverService();
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String dname =  request.getParameter("dname");
		String dsex =  request.getParameter("dsex");
		String idcard =  request.getParameter("idcard");
		String ctype =  request.getParameter("ctype");
		String dstatus =  request.getParameter("dstatus");
		String username =  request.getParameter("username");
		String rolm =  request.getParameter("rolm");
		
		Driver driver = new Driver();
		
		driver.setCtype(ctype);
		driver.setDname(dname);
		driver.setDsex(dsex);
		driver.setDstatus(dstatus);
		driver.setIdcard(idcard);
		driver.setRolm(rolm);
		driver.setUsername(username);
		
		System.out.println(driverService.addUser(driver) );
		
		response.getWriter().append("ok");
	}
}
